package com.mangguo.tingjian.activity.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.Lists;
import com.mangguo.tingjian.activity.dto.*;
import com.mangguo.tingjian.activity.req.ActivityPageReq;
import com.mangguo.tingjian.activity.req.ActivityTrendReq;
import com.mangguo.tingjian.activity.req.ChannelPageReq;
import com.mangguo.tingjian.activity.req.ChannelTrendReq;
import com.mangguo.tingjian.activity.service.IDwChannelOpenAppService;
import com.mangguo.tingjian.common.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author auto
 * @since 2019-11-25
 */
@RestController
@RequestMapping("/app")
public class DwChannelOpenAppController {

    @Resource
    private IDwChannelOpenAppService dwChannelOpenAppService;

    @GetMapping("/activity/all-activity")
    public Result<SubChannelResult> getAllActivitis(){
        return Result.success(SubChannelResult.builder().subChannels(Lists.newArrayList("201111016")).build());
    }

    /**
     * 今日活动拉新数据
     */
    @GetMapping("/activity/today-activity-data")
    public Result<TodayActivityResult> todayActivityOpenData(@RequestParam(value = "subChannelId") String subChannelId){
        TodayActivityResult todayActivityResult = dwChannelOpenAppService.getTodayActivityData(subChannelId);
        return Result.success(todayActivityResult);
    }

    /**
     * 活动趋势数据（小时级别）
     * @param activityTrendReq
     * @return
     */
    @GetMapping("/activity/activity-trend-data")
    public Result<List<ActivityTrendData> > getActivityTrendData(ActivityTrendReq activityTrendReq){
        return Result.success(dwChannelOpenAppService.getActivityTrend(activityTrendReq));
    }

    /**
     * 今日活动排行数据
     * @return
     */
    @GetMapping("/activity/today-activity-rank-data")
    public Result getRankActivityData(@RequestParam Integer processType){
        return Result.success(dwChannelOpenAppService.getTodayActivityRankResult(processType));
    }

    /**
     * 活动排行数据（分页）
     * @return
     */
    @GetMapping("/activity/activity-rank-page-data")
    public Result getPageRankActivityData(ActivityPageReq req){
        return Result.success(dwChannelOpenAppService.getActivityPageResult(req));
    }



    //渠道数据
    @GetMapping("/channel/all-channel")
    public Result<ChannelResult> getAllChannels(){
        return Result.success(ChannelResult.builder().channels(Lists.newArrayList("201111016")).build());
    }

    /**
     * 今日活动拉新数据
     */
    @GetMapping("/channel/today-channel-data")
    public Result<TodayChannelResult> todayChannelOpenData(@RequestParam(value = "channelId") String channelId){
        TodayChannelResult todayActivityResult = dwChannelOpenAppService.getTodayChannelData(channelId);
        return Result.success(todayActivityResult);
    }

    /**
     * 活动趋势数据（小时级别）
     * @param channelTrendReq
     * @return
     */
    @GetMapping("/channel/channel-trend-data")
    public Result<List<ChannelTrendData>> getChannelTrendData(ChannelTrendReq channelTrendReq){
        return Result.success(dwChannelOpenAppService.getChannelTrend(channelTrendReq));
    }

    /**
     * 今日活动排行数据
     * @return
     */
    @GetMapping("/channel/today-channel-rank-data")
    public Result<List<TodayChannelRankResult>> getRankChannelData(@RequestParam Integer processType){
        return Result.success(dwChannelOpenAppService.getChannelActivityRankResult(processType));
    }

    /**
     * 活动排行数据（分页）
     * @return
     */
    @GetMapping("/channel/channel-rank-page-data")
    public Result<IPage<TodayChannelResult>> getPageRankChannelData(ChannelPageReq req){
        return Result.success(dwChannelOpenAppService.getChannelPageResult(req));
    }

}
